<!-- 管理员页面 -->
<template>
  <div>
    
    <el-container>
      
      <el-aside :width="asideWidth"  style="min-height: 100vh; background-color: #001529;">
        <div style="height: 60px; color : white ;display:flex ;justify-content: center; align-items: center;" >
          <img src="@/assets/logo.png" alt="logo" style="width: 40px; height: 40px; margin-right: 10px;">
          <span class="logo" style="font-size: 20px;" v-show="!isCollapse">管理系统</span>
          
        </div>
<!-- 记得下面加router进行页面切换 -->
        <el-menu  :collapse="isCollapse" collapse-transition="false" background-color="#001529"  style="border: none;" default-active="1" class="el-menu-vertical-demo" @open="handleOpen" @close="handleClose">
            <el-menu-item index="1">
            <i class="el-icon-search"></i>
            <span slot="title">仪表盘</span>
            
            </el-menu-item>
            <el-menu-item index="2">
              <i class="el-icon-user"></i>
              <span slot="title">用户管理</span>
            </el-menu-item>

            <el-menu-item index="3">
              <i class="el-icon-document"></i>
              <span slot="title">咨询分类</span>
            </el-menu-item>

           <el-menu-item index="4">
              <i class="el-icon-files"></i>
              <span slot="title">模型管理</span>
            </el-menu-item>

            <el-menu-item index="5">
              <i class="el-icon-tickets"></i>
              <span slot="title">健康记录</span>
            </el-menu-item>

            <el-menu-item index="6">
              <i class="el-icon-message"></i>
              <span slot="title">消息管理</span>
            </el-menu-item>

           <el-menu-item index="7">
              <i class="el-icon-view"></i>
              <span slot="title">评论管理</span>
           </el-menu-item>
        </el-menu>
      </el-aside>

      <el-container>
        <el-header>
          <i :class="collapseicon" class="el-icon-menu" style="width: 50px;font-size: 26px;" @click="handlecollapse"></i>
          <el-breadcrumb separator-class="el-icon-arrow-right">
          <el-breadcrumb-item :to="{ path: '/' }">首页</el-breadcrumb-item>
          <el-breadcrumb-item :to="{ path: '/user'}">用户管理</el-breadcrumb-item>
        </el-breadcrumb>

        <div style="flex: 1;width: 0; display: flex; align-items: center; justify-content: flex-end;">
            <el-dropdown>
              <div style="display: flex; align-items: center; cursor: pointer;">
                <img src="@/assets/logo.png" alt="logo" style="width: 40px; height: 40px; margin-right: 10px;">
                <span>管理员</span>
              </div>
               
               <el-dropdown-menu slot="dropdown" placement="bottom-end">
                  <el-dropdown-item>个人信息</el-dropdown-item>
                  <el-dropdown-item>修改密码</el-dropdown-item>
                  <el-dropdown-item >退出登录</el-dropdown-item>
                  <!-- <el-dropdown-item @click="点击事件">退出登录</el-dropdown-item> -->
               </el-dropdown-menu>
            </el-dropdown>
        </div>

        </el-header>

        <el-main>
          <div style="box-shadow: 0 0 10px rgba(0,0, 0,.1 ); padding :10px 20px ;border-radius: 5px; margin-bottom:10px ;">
            欢迎来到健康管理系统
          </div>

          <div style="display: flex;">
            <el-card style="width: 50%; margin-right: 10px;">
              <div slot="header" class="clearfix">
                <span>用户统计</span>
              </div>

              <div>
                2025年1月1日 - 2025年12月31日
                <div style="margin-top: 20px;">
                  <el-progress :percentage="70" status="success" :text-inside="true" :stroke-width="18"></el-progress>
                </div>
              </div>
            </el-card>

            <el-card style="width: 50%; margin-right: 10px;">
              <div slot="header" class="clearfix">
                <span>用户统计</span>
              </div>

              <div>
                <el-table :data="users">
                  <el-table-column prop="id" label="ID" ></el-table-column>
                  <el-table-column prop="account" label="账户" ></el-table-column>
                  <el-table-column prop="email" label="邮箱" ></el-table-column>
                  <el-table-column prop="role" label="角色" ></el-table-column>
                </el-table>
              </div>
            </el-card>
          </div>
        </el-main>

      </el-container>
    </el-container>
  </div>
</template>

<script>
import request from '@/utils/request';
import axios from 'axios';
import { Collapse } from 'element-ui';

export default {
  name: 'HomeView',
  data(){
    return {
      isCollapse: false, // 不收缩
      asideWidth: '200px', // 侧边栏宽度
      collapseicon: 'el-icon-s-fold', // 初始图标
      users:[]
    }
  },
  methods:{
    handlecollapse(){
      this.isCollapse = !this.isCollapse; // 切换收缩状态
      this.collapseicon = this.isCollapse ? 'el-icon-s-unfold' : 'el-icon-s-fold'; // 切换图标
      this.asideWidth = this.isCollapse ? '64px' : '200px'; // 根据收缩状态调整宽度
    }
  },
  mounted(){
    // axios.get("http://localhost:8080/user/selectall").then(res=>{
    //   this.users=res.data.data;
    // })
    request.get('/user/selectall')
      request.get('/user/selectall')
     .then(res => {
     this.users = res.data; // 或 this.users = res;
      })
      .catch(error => {
        console.error('获取用户数据失败:', error);
      });
  }
}
</script>
<style>
.el-menu-item{
  margin-top: 10px !important;
  height: 45px !important;
  line-height: 45px !important;
  color:#c7ece8 !important;
  background-color: #001529;
}
.el-menu-item:hover {
  color: #ffffff !important;
}
.el-menu-item:hover i{
  color: #ffffff !important;
}
.el-menu--collapse {
  margin: 0 5px 18px 5px !important;
  align-items: center;
  margin: 0 !important;
  justify-content: center;
}
.el-menu-item.is-active{
  border-radius: 5px;
  background-color:#40a9ff !important;
}
.el-aside{
  transition:width .6s;
  box-shadow: 2px 0 6px rgba(0,21,41,.35);
}
.logo{
  margin-left: 5px;
  font-size: 20px;
  transition: all 0.6s;
}
.el-header{
  display: flex;
  align-items: center;
  box-shadow: 2px 0 6px rgba(0,21,41,.35);
}
</style>